#include<iostream>
#include<pthread.h>
#include"Mutex.hpp"

namespace CondModule
{
    using namespace Lock;
    //条件变量
    class Cond
    {
        
        public:
        Cond()
        {
            int n = pthread_cond_init(&con,nullptr);
            (void)n;
        }
        void Wait(Mutex& mut)
        {
            int n = pthread_cond_wait(&con,mut.LockPtr());
            (void)n;
        }
        void Signal()
        {
            int n = pthread_cond_signal(&con);
            (void)n;
        }
        void SingalAll()
        {
            int n =pthread_cond_broadcast(&con);
            (void)n;
        }
        ~Cond()
        {
            int n = pthread_cond_destroy(&con);
            (void) n;
        }
        private:
        pthread_cond_t con;
    };


}